package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.eschool.model.Room;
import com.eschool.model.Teacher;

public class RoomDataModel extends ListDataModel<Room> implements SelectableDataModel<Room>, Serializable {  

    public RoomDataModel() {
    }

    public RoomDataModel(List<Room> data) {
        super(data);
    }
    
    @Override
    public Room getRowData(String rowKey) {
        List<Room> rooms = (List<Room>) getWrappedData();
        
		for (Room room : rooms) {
            if(Integer.toString(room.getRoomId()).equals(rowKey))
                return room;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(Room room) {
        return room.getRoomId();
    }
}